package com.lwq.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lwq.entity.Permission;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * 会员表 Mapper 接口
 * </p>
 *
 * @author lwq
 * @since 2023-02-13
 */
@Repository
public interface PermissionMapper extends BaseMapper<Permission> {

    /**
     * 按用户表主键查询该用户的全部权限
     *
     * @param memberId 用户表主键
     * @return 该用户的全部权限
     */
    @Select("select p.permission_id, p.permission_title, p.permission_info, p.create_time, p.last_modify " +
            "from alibaba.role_permission rp " +
            "join permission p on rp.permission_id = p.permission_id " +
            "where role_id in ( " +
            "        select role_id from alibaba.member_role mr where mr.member_id = #{param1}" +
            "    )")
    List<Permission> selectPermissionsByMemberId(Integer memberId);
}
